package com.hvtt.web.models;

import com.hvtt.web.controller.Sys_NguoiDungController;
import com.hvtt.web.utilities.Utilities;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.Serializable;
import org.primefaces.component.fileupload.FileUpload;
import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;
import org.primefaces.model.UploadedFile;

public class C_hinhanh_xe implements Serializable{
	private long iD = 0;
	private long iDPhu = 0;
	private String hinhAnh = "";
        private String oldHinhAnh = "";
	private boolean hinhAnhChinh = false;
        private UploadedFile tapTin=null;
        private StreamedContent fileHinhAnh=null;
	public C_hinhanh_xe() {}
	public C_hinhanh_xe (long iD,long iDPhu,String hinhAnh,boolean hinhAnhChinh){
		this.iD = iD;
		this.iDPhu = iDPhu;
		this.hinhAnh = hinhAnh;
		this.hinhAnhChinh = hinhAnhChinh;
                this.tapTin=null;
	}
	public long getID(){return iD;}
	public void setID(long iD){ this.iD = iD;}
	public long getIDPhu(){return iDPhu;}
	public void setIDPhu(long iDPhu){ this.iDPhu = iDPhu;}
	public String getHinhAnh(){return hinhAnh;}
	public void setHinhAnh(String hinhAnh){ this.hinhAnh = hinhAnh;}
	public boolean getHinhAnhChinh(){return hinhAnhChinh;}
	public void setHinhAnhChinh(boolean hinhAnhChinh){ this.hinhAnhChinh = hinhAnhChinh;}
	public void resetAttribute() {
		iD = 0;
		iDPhu = 0;
		hinhAnh = "";
		hinhAnhChinh = false;
                tapTin=null;
                setFileHinhAnh(null);
	}
        
        public void setOldHinhAnh(String oldHinhAnh){ this.oldHinhAnh = oldHinhAnh;}
	public String getOldHinhAnh(){return oldHinhAnh;}
        
        public UploadedFile getTapTin(){return tapTin;}
	public void setTapTin(UploadedFile tapTin){ this.tapTin = tapTin;}

    /**
     * @return the fileHinhAnh
     */
    public StreamedContent getFileHinhAnh() {
        if(fileHinhAnh==null)
        {
            File file = new File(Utilities.GetPathUserUploadFile()+  File.separator + Sys_NguoiDungController.findUser().getUserID()+ File.separator + "");
        }
        return fileHinhAnh;
    }

    /**
     * @param fileHinhAnh the fileHinhAnh to set
     */
    public void setFileHinhAnh(StreamedContent fileHinhAnh) {
        this.fileHinhAnh = fileHinhAnh;
    }
}